{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "58747ea4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0c1511d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>学号</th>\n",
       "      <th>姓名</th>\n",
       "      <th>计算机</th>\n",
       "      <th>英语</th>\n",
       "      <th>大学语文</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>P0245</td>\n",
       "      <td>小明</td>\n",
       "      <td>50</td>\n",
       "      <td>59</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>P0246</td>\n",
       "      <td>小美</td>\n",
       "      <td>67</td>\n",
       "      <td>76</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>P0247</td>\n",
       "      <td>小丽</td>\n",
       "      <td>81</td>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>P0248</td>\n",
       "      <td>小黄</td>\n",
       "      <td>46</td>\n",
       "      <td>76</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>P0249</td>\n",
       "      <td>小陈</td>\n",
       "      <td>89</td>\n",
       "      <td>35</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      学号  姓名  计算机  英语  大学语文\n",
       "0  P0245  小明   50  59    75\n",
       "1  P0246  小美   67  76    73\n",
       "2  P0247  小丽   81  98    58\n",
       "3  P0248  小黄   46  76    76\n",
       "4  P0249  小陈   89  35    73"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息 = pd.read_excel(R'C:\\Users\\1126\\Desktop\\htt\\ck\\data\\xls\\学生信息.xlsx')\n",
    "学生信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e32dc1a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    小明\n",
       "1    小美\n",
       "2    小丽\n",
       "3    小黄\n",
       "4    小陈\n",
       "Name: 姓名, dtype: object"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.姓名\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "a619eb7f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    75\n",
       "1    73\n",
       "2    58\n",
       "3    76\n",
       "4    73\n",
       "Name: 大学语文, dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.大学语文"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "67508af6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>大学语文</th>\n",
       "      <th>英语</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>75</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>73</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>58</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>76</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>73</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   大学语文  英语\n",
       "0    75  59\n",
       "1    73  76\n",
       "2    58  98\n",
       "3    76  76\n",
       "4    73  35"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息[['大学语文','英语']]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "29f406bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(75)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.loc[0,\"大学语文\"]\n",
    "# loc 是根据标签索引数据，通常用于行索引和列索引，第一个参数是行索引，第二个参数是列索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "fc717d91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "学号      P0247\n",
       "姓名         小丽\n",
       "计算机        81\n",
       "英语         98\n",
       "大学语文       58\n",
       "Name: 2, dtype: object"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.loc[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "22938fbf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "大学语文    58\n",
       "英语      98\n",
       "Name: 2, dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.loc[2,['大学语文','英语']]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "6863e53e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>大学语文</th>\n",
       "      <th>英语</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>73</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>58</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   大学语文  英语\n",
       "1    73  76\n",
       "2    58  98"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.loc[[1,2],['大学语文','英语']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "450aecb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>大学语文</th>\n",
       "      <th>英语</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>73</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>58</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>76</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>73</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   大学语文  英语\n",
       "1    73  76\n",
       "2    58  98\n",
       "3    76  76\n",
       "4    73  35"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "学生信息.loc[1:4,['大学语文','英语']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "aaf8a4ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "list1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,20]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "fab20ae0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list1[2:12]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "678e3127",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 什么是布尔列表\n",
    "# 布尔列表是指列表中每个元素都是布尔值的列表\n",
    "# 例如：[True, False, True, False, True]\n",
    "# 布尔列表在数据分析中非常常用，因为它可以用来筛选数据\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
